package eleven.test_11_21;

import java.util.Scanner;

public class TestMain4 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        char[] ch = str.toCharArray();
        int r = -1;
        int e = -1;
        int start = -1;
        int i = 0;
        int count = 0;
        while (i < ch.length && ch[i] == 'd') {
            i++;
        }
        start = i - 1;
        for(; i < ch.length; i++) {
            if(ch[i] == 'r' && (e == -1 || r == -1)) {
                r = i;
            } else if(ch[i] == 'e' && (r == -1 || e == -1)) {
                e = i;
            } else if(ch[i] == 'r' && r != 1 && e != -1) {
                if(Math.abs(i - e) <= Math.abs(r - e)) {
                    r = i;
                }
            } else if(ch[i] == 'e' && r != -1 && e != 1) {
                if(Math.abs(i - r) <= Math.abs(e - r)) {
                    e = i;
                }
            } else if(ch[i] == 'd') {
                int min = Math.min(r,e);
                int max = Math.max(r,e);
                count += (i - max) * (min - start);
                r = -1;
                e = -1;
                start = i;
            }
        }
        System.out.println(count);
    }
}
